home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWODUtil / Include / FWSUSink.h < prev   
Encoding:
Text File  |  1995-11-08  |  2.5 KB  |  102 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWSUSink.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWSUSINK_H
  11. #define FWSUSINK_H
  12.  
  13. #ifndef FWASINKS_H
  14. #include "FWASinks.h"
  15. #endif
  16.  
  17. #ifndef FWSUBUFF_H
  18. #include "FWSUBuff.h"
  19. #endif
  20.  
  21. // ----- OpenDoc Includes -----
  22.  
  23. #ifndef SOM_ODStorageUnit_xh
  24. #include <StorageU.xh>
  25. #endif
  26.  
  27. #ifndef SOM_ODStorageUnitView_xh
  28. #include <SUView.xh>
  29. #endif
  30.  
  31. #if FW_LIB_EXPORT_PRAGMAS
  32. #pragma lib_export on
  33. #endif
  34.  
  35. //========================================================================================
  36. //    •• CLASS FW_CStorageUnitSink
  37. //========================================================================================
  38.  
  39. class FW_CLASS_ATTR FW_CStorageUnitSink : public FW_CRandomAccessSink
  40. {
  41. public:
  42.  
  43.     virtual ~ FW_CStorageUnitSink();
  44.     
  45.     FW_CStorageUnitSink(ODStorageUnitView* storageUnitView);
  46.         // Create a sink attached to the storage unit view.
  47.         // The sink does not assume ownership of the view.
  48.          
  49.     FW_CStorageUnitSink(ODStorageUnit* storageUnit, ODPropertyName propertyName, ODValueType valueType);
  50.         // Create a sink attached to the give (storageUnit, propertyName, valueType).
  51.     
  52.     ODStorageUnitView*    GetStorageUnitView() const;
  53.     
  54. public:
  55.  
  56.     // ----- Random Access Sink Protocol
  57.     
  58.     virtual void Read(void* destination, long count);
  59.     const void*  ReadPeek(long& availableReadBytes);
  60.     void         ReadPeekAdvance(long bytesRead);
  61.     
  62.     virtual long GetWritableBytes() const;
  63.     virtual void Write(const void* source, long count);
  64.     void*           WritePeek(long& availableWriteBytes);
  65.     void         WritePeekAdvance(long bytesWritten);
  66.  
  67.     virtual long GetLength() const;
  68.     virtual void SetLength(long length);
  69.     virtual long GetPosition() const;
  70.     virtual void SetPosition(long position);
  71.     
  72. public:
  73.  
  74.     // ----- New API
  75.     
  76.     void         Flush();  // flush buffer to disk
  77.     
  78. private:
  79.     ODStorageUnitView*        fStorageUnitView;
  80.     FW_Boolean                fOwnsView;
  81.     
  82.     FW_CStorageUnitBuffer    fBuffer;  // buffer for optimized reading/writing
  83.     
  84. private:
  85.     FW_CStorageUnitSink(const FW_CStorageUnitSink& sink);
  86.         // Copying not allowed
  87.         
  88.     FW_CStorageUnitSink& operator=(const FW_CStorageUnitSink& sink);
  89.         // Copying not allowed
  90.  
  91.     void PrivAcquire();
  92.  
  93.     void PrivDoRead(void* destination, long count);
  94.     void PrivDoWrite(const void* source, long count);
  95. };
  96.  
  97. #if FW_LIB_EXPORT_PRAGMAS
  98. #pragma lib_export off
  99. #endif
  100.  
  101. #endif
  102.